package com.springbootmybatiscurd.service.serviceimpl;


import com.springbootmybatiscurd.mapper.emp.DmpMapper;
import com.springbootmybatiscurd.pojo.Dept;

import com.springbootmybatiscurd.service.deptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements deptService {
    @Autowired
    private DmpMapper dmpMapper;


    @Override
    public List<Dept> DeptService() {
        List<Dept> depts = dmpMapper.selectDept();
        System.out.println(depts);
        return depts;
    }

    @Override
    public Integer deleteId(Integer id) {
        Integer deptId = dmpMapper.deleteId(id);
        return deptId;
    }

    @Override
    public void addDept(Dept dept) {

        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());

        dmpMapper.addDept(dept);
    }

    @Override
    public List<Dept> selectId(Integer id) {
        List<Dept> depts = dmpMapper.selectId(id);
        return depts;
    }

    @Override
    public void deptUpdate(Dept dept) {

        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
         dmpMapper.deptUpdate(dept);



    }
}
